package com.control 
{
	import com.data.GameData;
	import flash.display.MovieClip;
	/**
	 * ...
	 * @author wen
	 */
	public class BgSwitch 
	{
		private var _mc0:MovieClip;
		
		private var _mc1:MovieClip;
		
		private var _pos:Array;
		
		private var _curMc:String;
		
		private var _height:Number;
		
		public function BgSwitch(mc0:MovieClip,mc1:MovieClip) 
		{
			_mc0 = mc0;
			_mc1 = mc1;
			
			_pos = [_mc0.y, _mc1.y];
			_height = _mc0.height;
		}
		
		public function init():void
		{
			_mc0.y = _pos[0];
			_mc1.y = _pos[1];
			
			_curMc = "mc0";
		}
		
		public function check():void
		{
			var tmpY:Number = GameData.rabbit.y;
			
			if (tmpY > _mc0.y && (tmpY < _mc0.y + _height)) 
			{
				_curMc = "mc0";
			}
			else
			{
				_curMc = "mc1";
			}
			
			if (_curMc == "mc0")
			{
				if (tmpY - _mc0.y < 300)
				{
					_mc1.y = _mc0.y - _height;
				}
				if (tmpY > _mc0.y + _height-300)
				{
					_mc1.y = _mc0.y + _height;
				}
			}
			else
			{
				if (tmpY - _mc1.y < 300)
				{
					_mc0.y = _mc1.y - _height;
				}
				if (tmpY > _mc1.y + _height-300)
				{
					_mc0.y = _mc1.y + _height;
				}
			}
			
			
		}
	}

}